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

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

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

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

g = A("g")
e = B("e")
a = C("a")
b = D("b")
m = A("m")
h = A("h")

g.o = e
g.r = e
g.t = m
e.t = a
a.o = h
b.s = e
b.o = m
b.w = a
m.o = e
m.r = e
m.t = g
h.o = e
h.r = e
h.t = g
assert g.t.t.r.t.o.t.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.t: A = None
        self.r: B = None
        self.txt = txt

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

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

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

g = A("g")
e = B("e")
a = C("a")
b = D("b")
m = A("m")
h = A("h")

g.o = e
g.r = e
g.t = m
e.t = a
a.o = h
b.s = e
b.o = m
b.w = a
m.o = e
m.r = e
m.t = g
h.o = e
h.r = e
h.t = g
assert g.t.t.r.t.o.t.txt == "g"