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

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

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

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

g = A("g")
d = B("d")
b = C("b")
n = D("n")
c = B("c")
h = D("h")
e = D("e")

g.w = h
g.z = d
g.x = b
d.w = g
d.t = b
d.p = b
d.o = n
b.r = c
b.s = h
n.s = b
n.t = b
n.p = g
c.w = g
c.t = b
c.p = b
c.o = e
h.s = b
h.t = b
h.p = g
e.s = b
e.t = b
e.p = g
assert b.s.s.s.t.txt == "
class A:
    def __init__(self, txt: str):
        self.w: D = None
        self.z: B = None
        self.x: C = None
        self.txt = txt

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

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

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

g = A("g")
d = B("d")
b = C("b")
n = D("n")
c = B("c")
h = D("h")
e = D("e")

g.w = h
g.z = d
g.x = b
d.w = g
d.t = b
d.p = b
d.o = n
b.r = c
b.s = h
n.s = b
n.t = b
n.p = g
c.w = g
c.t = b
c.p = b
c.o = e
h.s = b
h.t = b
h.p = g
e.s = b
e.t = b
e.p = g
assert b.s.s.s.t.txt == "b"