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

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

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

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

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

h.t = n
c.o = g
n.t = i
n.z = g
i.t = n
i.r = b
i.w = g
g.t = n
b.t = n
b.r = i
b.w = h
assert b.t.z.t.t.r.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

h.t = n
c.o = g
n.t = i
n.z = g
i.t = n
i.r = b
i.w = g
g.t = n
b.t = n
b.r = i
b.w = h
assert b.t.z.t.t.r.t.txt == "n"