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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: D = None
        self.v: D = None
        self.z: D = None
        self.txt = txt

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

g = A("g")
d = B("d")
j = C("j")
i = D("i")
l = B("l")

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

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

class C:
    def __init__(self, txt: str):
        self.y: A = None
        self.x: D = None
        self.v: D = None
        self.z: D = None
        self.txt = txt

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

g = A("g")
d = B("d")
j = C("j")
i = D("i")
l = B("l")

g.u = j
d.v = g
j.y = g
j.x = i
j.v = i
j.z = i
i.s = j
i.o = j
l.v = g
assert i.o.x.o.y.u.txt == "j"