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

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: C = None
        self.v: C = None
        self.txt = txt

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

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

g.r = b
h.u = g
h.z = j
h.o = j
b.p = d
b.y = d
b.v = d
j.t = g
j.y = l
d.p = b
d.y = b
d.v = b
l.u = g
l.z = j
l.o = j
assert b.p.p.y.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: C = None
        self.y: C = None
        self.v: C = None
        self.txt = txt

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

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

g.r = b
h.u = g
h.z = j
h.o = j
b.p = d
b.y = d
b.v = d
j.t = g
j.y = l
d.p = b
d.y = b
d.v = b
l.u = g
l.z = j
l.o = j
assert b.p.p.y.txt == "d"