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

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

d = A("d")
k = B("k")
f = C("f")
j = D("j")
c = E("c")
h = F("h")
g = A("g")

d.y = j
d.p = k
k.u = f
k.r = c
k.q = c
k.w = c
k.t = c
k.y = h
f.v = g
j.o = h
j.t = f
c.o = h
h.v = f
g.y = j
g.p = k
assert k.u.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.p: B = None
        self.txt = txt

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

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

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

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

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.txt = txt

d = A("d")
k = B("k")
f = C("f")
j = D("j")
c = E("c")
h = F("h")
g = A("g")

d.y = j
d.p = k
k.u = f
k.r = c
k.q = c
k.w = c
k.t = c
k.y = h
f.v = g
j.o = h
j.t = f
c.o = h
h.v = f
g.y = j
g.p = k
assert k.u.v.p.txt == "k"