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

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: A = None
        self.o: B = None
        self.q: A = None
        self.txt = txt

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

l.x = b
l.y = k
i.x = d
g.x = i
g.v = l
g.z = d
g.r = b
k.t = g
k.z = l
k.q = l
k.o = d
b.x = d
b.v = l
b.z = i
b.r = g
d.x = i
assert l.y.t.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.y: D = None
        self.txt = txt

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

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

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.z: A = None
        self.o: B = None
        self.q: A = None
        self.txt = txt

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

l.x = b
l.y = k
i.x = d
g.x = i
g.v = l
g.z = d
g.r = b
k.t = g
k.z = l
k.q = l
k.o = d
b.x = d
b.v = l
b.z = i
b.r = g
d.x = i
assert l.y.t.x.x.txt == "d"