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

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: D = None
        self.o: C = None
        self.z: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: F = None
        self.x: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

d = A("d")
b = B("b")
f = C("f")
i = D("i")
j = E("j")
a = F("a")
c = B("c")
n = F("n")

d.y = f
d.p = f
b.r = d
b.v = i
b.o = f
b.z = j
f.w = d
i.t = a
i.p = f
j.s = d
j.w = a
j.x = f
a.s = i
c.r = d
c.v = i
c.o = f
c.z = j
n.s = i
assert n.s.t.s.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.p: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: A = None
        self.v: D = None
        self.o: C = None
        self.z: E = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.s: A = None
        self.w: F = None
        self.x: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.s: D = None
        self.txt = txt

d = A("d")
b = B("b")
f = C("f")
i = D("i")
j = E("j")
a = F("a")
c = B("c")
n = F("n")

d.y = f
d.p = f
b.r = d
b.v = i
b.o = f
b.z = j
f.w = d
i.t = a
i.p = f
j.s = d
j.w = a
j.x = f
a.s = i
c.r = d
c.v = i
c.o = f
c.z = j
n.s = i
assert n.s.t.s.p.txt == "f"