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

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

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

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

a = A("a")
b = B("b")
g = C("g")
c = D("c")
i = B("i")
e = D("e")
f = D("f")
l = C("l")
n = C("n")

a.r = e
a.u = b
a.x = b
b.w = l
b.x = i
g.z = l
g.r = n
c.p = b
i.w = n
i.x = b
e.p = i
f.p = b
l.z = g
l.r = n
n.z = l
n.r = g
assert i.x.x.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.u: B = None
        self.x: B = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
g = C("g")
c = D("c")
i = B("i")
e = D("e")
f = D("f")
l = C("l")
n = C("n")

a.r = e
a.u = b
a.x = b
b.w = l
b.x = i
g.z = l
g.r = n
c.p = b
i.w = n
i.x = b
e.p = i
f.p = b
l.z = g
l.r = n
n.z = l
n.r = g
assert i.x.x.w.z.txt == "l"