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

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.q: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: A = None
        self.q: F = None
        self.o: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.r: B = None
        self.txt = txt

b = A("b")
h = B("h")
k = C("k")
a = D("a")
l = E("l")
c = F("c")
f = F("f")

b.r = c
h.u = l
h.q = a
k.p = b
k.y = a
a.u = b
a.z = k
l.t = a
l.o = a
l.u = b
l.q = c
c.t = l
c.r = h
f.t = l
f.r = h
assert f.r.q.z.y.z.p.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: E = None
        self.q: D = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.t: D = None
        self.u: A = None
        self.q: F = None
        self.o: D = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.t: E = None
        self.r: B = None
        self.txt = txt

b = A("b")
h = B("h")
k = C("k")
a = D("a")
l = E("l")
c = F("c")
f = F("f")

b.r = c
h.u = l
h.q = a
k.p = b
k.y = a
a.u = b
a.z = k
l.t = a
l.o = a
l.u = b
l.q = c
c.t = l
c.r = h
f.t = l
f.r = h
assert f.r.q.z.y.z.p.r.txt == "c"