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

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

d.t = n
d.v = h
d.r = h
a.w = b
a.t = f
f.x = d
f.p = d
f.q = b
b.v = f
b.r = a
b.p = a
i.p = a
h.r = i
h.z = i
n.t = d
n.v = h
n.r = h
assert i.p.w.v.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: A = None
        self.v: F = None
        self.r: F = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.p: B = None
        self.txt = txt

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

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

d.t = n
d.v = h
d.r = h
a.w = b
a.t = f
f.x = d
f.p = d
f.q = b
b.v = f
b.r = a
b.p = a
i.p = a
h.r = i
h.z = i
n.t = d
n.v = h
n.r = h
assert i.p.w.v.q.txt == "b"