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

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

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

g = A("g")
e = B("e")
h = C("h")
b = A("b")
l = C("l")
c = B("c")
d = B("d")
i = A("i")
m = A("m")
f = A("f")

g.p = d
e.y = c
e.w = d
e.r = d
h.r = l
h.o = f
b.p = d
l.r = h
l.o = m
c.y = e
c.w = e
c.r = d
d.y = c
d.w = c
d.r = e
i.p = e
m.p = e
f.p = d
assert g.p.r.w.y.w.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

g = A("g")
e = B("e")
h = C("h")
b = A("b")
l = C("l")
c = B("c")
d = B("d")
i = A("i")
m = A("m")
f = A("f")

g.p = d
e.y = c
e.w = d
e.r = d
h.r = l
h.o = f
b.p = d
l.r = h
l.o = m
c.y = e
c.w = e
c.r = d
d.y = c
d.w = c
d.r = e
i.p = e
m.p = e
f.p = d
assert g.p.r.w.y.w.y.y.txt == "e"