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

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

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

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

i = A("i")
g = B("g")
k = C("k")
b = D("b")
e = B("e")
a = D("a")

i.p = k
i.t = e
g.t = e
g.p = e
g.r = e
g.o = b
k.r = g
b.y = i
b.o = a
e.t = g
e.p = g
e.r = g
e.o = a
a.y = i
a.o = b
assert g.p.t.t.r.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.t: B = None
        self.txt = txt

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

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

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

i = A("i")
g = B("g")
k = C("k")
b = D("b")
e = B("e")
a = D("a")

i.p = k
i.t = e
g.t = e
g.p = e
g.r = e
g.o = b
k.r = g
b.y = i
b.o = a
e.t = g
e.p = g
e.r = g
e.o = a
a.y = i
a.o = b
assert g.p.t.t.r.p.p.txt == "g"