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

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: F = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

d = A("d")
c = B("c")
f = C("f")
n = D("n")
j = E("j")
l = F("l")
h = D("h")

d.p = c
d.u = l
d.v = h
c.q = d
c.v = d
c.u = l
c.p = f
f.z = d
f.w = h
n.p = h
n.s = c
n.r = j
j.v = n
j.o = n
j.r = c
l.y = c
h.p = n
h.s = c
h.r = j
assert d.u.y.v.txt == "
class A:
    def __init__(self, txt: str):
        self.p: B = None
        self.u: F = None
        self.v: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.u: F = None
        self.v: A = None
        self.p: C = None
        self.txt = txt

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

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

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

class F:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

d = A("d")
c = B("c")
f = C("f")
n = D("n")
j = E("j")
l = F("l")
h = D("h")

d.p = c
d.u = l
d.v = h
c.q = d
c.v = d
c.u = l
c.p = f
f.z = d
f.w = h
n.p = h
n.s = c
n.r = j
j.v = n
j.o = n
j.r = c
l.y = c
h.p = n
h.s = c
h.r = j
assert d.u.y.v.txt == "d"