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

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

class C:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: E = None
        self.u: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

f = A("f")
b = B("b")
d = C("d")
l = D("l")
c = E("c")
m = F("m")

f.r = d
b.r = d
d.x = m
d.r = c
d.u = l
l.q = c
l.x = b
l.o = m
c.z = l
m.t = f
m.u = f
m.y = d
m.w = d
m.p = b
assert b.r.r.z.o.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: E = None
        self.u: D = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.z: D = None
        self.txt = txt

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

f = A("f")
b = B("b")
d = C("d")
l = D("l")
c = E("c")
m = F("m")

f.r = d
b.r = d
d.x = m
d.r = c
d.u = l
l.q = c
l.x = b
l.o = m
c.z = l
m.t = f
m.u = f
m.y = d
m.w = d
m.p = b
assert b.r.r.z.o.p.txt == "b"