class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.u: A = None
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: A = None
        self.x: D = None
        self.txt = txt

e = A("e")
l = B("l")
g = C("g")
j = D("j")
h = D("h")

e.o = g
l.y = j
g.s = j
g.u = e
g.y = h
j.v = l
j.u = e
j.x = h
h.v = l
h.u = e
h.x = j
assert g.u.o.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.s: D = None
        self.u: A = None
        self.y: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: A = None
        self.x: D = None
        self.txt = txt

e = A("e")
l = B("l")
g = C("g")
j = D("j")
h = D("h")

e.o = g
l.y = j
g.s = j
g.u = e
g.y = h
j.v = l
j.u = e
j.x = h
h.v = l
h.u = e
h.x = j
assert g.u.o.u.txt == "e"