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

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

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

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

g = A("g")
i = B("i")
e = C("e")
b = D("b")
c = D("c")
m = B("m")

g.w = c
g.z = c
i.o = e
i.p = g
e.x = m
b.u = i
b.r = g
b.w = m
b.y = c
c.u = i
c.r = g
c.w = m
c.y = b
m.o = e
m.p = g
assert i.o.x.o.x.p.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
i = B("i")
e = C("e")
b = D("b")
c = D("c")
m = B("m")

g.w = c
g.z = c
i.o = e
i.p = g
e.x = m
b.u = i
b.r = g
b.w = m
b.y = c
c.u = i
c.r = g
c.w = m
c.y = b
m.o = e
m.p = g
assert i.o.x.o.x.p.txt == "g"