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

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

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

c = A("c")
l = B("l")
d = C("d")
h = B("h")
e = B("e")
n = A("n")
k = A("k")
b = B("b")
f = C("f")

c.y = e
c.p = n
c.u = f
l.q = b
l.w = f
d.y = f
h.q = b
h.w = f
e.q = b
e.w = d
n.y = l
n.p = c
n.u = f
k.y = h
k.p = n
k.u = d
b.q = h
b.w = d
f.y = d
assert f.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.p: A = None
        self.u: C = None
        self.txt = txt

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

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

c = A("c")
l = B("l")
d = C("d")
h = B("h")
e = B("e")
n = A("n")
k = A("k")
b = B("b")
f = C("f")

c.y = e
c.p = n
c.u = f
l.q = b
l.w = f
d.y = f
h.q = b
h.w = f
e.q = b
e.w = d
n.y = l
n.p = c
n.u = f
k.y = h
k.p = n
k.u = d
b.q = h
b.w = d
f.y = d
assert f.y.y.y.txt == "d"