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

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

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

g = A("g")
b = B("b")
k = C("k")
a = B("a")
h = A("h")
j = C("j")
d = B("d")
f = C("f")

g.y = f
g.r = j
b.o = h
b.p = d
k.y = b
a.o = h
a.p = b
h.y = j
h.r = j
j.y = b
d.o = h
d.p = b
f.y = b
assert k.y.o.r.y.p.o.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.r: C = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
k = C("k")
a = B("a")
h = A("h")
j = C("j")
d = B("d")
f = C("f")

g.y = f
g.r = j
b.o = h
b.p = d
k.y = b
a.o = h
a.p = b
h.y = j
h.r = j
j.y = b
d.o = h
d.p = b
f.y = b
assert k.y.o.r.y.p.o.y.y.txt == "b"