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

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

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

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

f = A("f")
i = B("i")
l = C("l")
c = D("c")
k = D("k")
m = A("m")
d = A("d")
a = C("a")
h = B("h")

f.r = m
i.p = a
i.q = a
i.w = k
i.y = m
l.y = i
l.v = i
c.y = a
c.z = f
c.s = k
k.y = a
k.z = f
k.s = c
m.r = f
d.r = f
a.y = h
a.v = i
h.p = l
h.w = c
h.y = m
h.q = a
assert f.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.txt = txt

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

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

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

f = A("f")
i = B("i")
l = C("l")
c = D("c")
k = D("k")
m = A("m")
d = A("d")
a = C("a")
h = B("h")

f.r = m
i.p = a
i.q = a
i.w = k
i.y = m
l.y = i
l.v = i
c.y = a
c.z = f
c.s = k
k.y = a
k.z = f
k.s = c
m.r = f
d.r = f
a.y = h
a.v = i
h.p = l
h.w = c
h.y = m
h.q = a
assert f.r.r.r.txt == "m"