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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: C = None
        self.p: A = None
        self.s: D = None
        self.o: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.o: F = None
        self.z: D = None
        self.w: D = None
        self.t: B = None
        self.txt = txt

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

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

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

class B:
    def __init__(self, txt: str):
        self.v: C = None
        self.w: C = None
        self.p: A = None
        self.s: D = None
        self.o: A = None
        self.txt = txt

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

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

class E:
    def __init__(self, txt: str):
        self.o: F = None
        self.z: D = None
        self.w: D = None
        self.t: B = None
        self.txt = txt

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

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

d.r = n
d.x = i
h.v = c
h.w = c
h.p = b
h.s = n
h.o = d
c.z = m
n.x = d
n.u = h
m.o = f
m.z = n
m.w = n
m.t = h
f.z = n
b.r = n
b.x = i
i.z = m
assert i.z.t.p.txt == "b"